//
//  NewsDetailVC.m
//  HelpThePoor
//
//  Created by van7ish on 2018/1/7.
//  Copyright © 2018年 van7ish. All rights reserved.
//

#import "NewsDetailVC.h"

@interface NewsDetailVC ()

/** 导航条 */
@property (nonatomic, strong) UIImageView * navBar;

@property (nonatomic, strong) UITextView *textView;

@end

@implementation NewsDetailVC

- (UIImageView *)navBar{
    if (!_navBar) {
        _navBar = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_W, 64)];
        _navBar.image = ImageNamed(@"daohangtiao");
    }
    return _navBar;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.title = @"资讯详情";
    
    [self.view addSubview:self.navBar];
    
    self.textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_W, SCREEN_H - 64)];
    
    NSString *htmlStr = self.dataDic[@"content"] ? : self.dataDic[@"summary"];
    
    if ([htmlStr containsString:@"src"] && ![htmlStr containsString:@"src=\"http://"]) {
        //需要拼接
        NSArray *arr = [htmlStr componentsSeparatedByString:@"src=\""];
        
        htmlStr = [arr componentsJoinedByString:@"src=\"http://jctsg.ndlib.cn"];
    }
    


    NSAttributedString *attrStr = [[NSAttributedString alloc] initWithData:[htmlStr dataUsingEncoding:NSUnicodeStringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType} documentAttributes:nil error:nil];
    self.textView.editable = NO;
    self.textView.font = [UIFont systemFontOfSize:16];
    self.textView.attributedText = attrStr;
    
    [self.view addSubview:self.textView];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
